<?php

include ('../session.php');
include ('../db.php');
include ('config.php');

$output = '';

$output .= "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
  <head>
    <title>Panic Points - List Events</title>
    <link href=\"../general.css\" rel=\"stylesheet\" type=\"text/css\">
  </head>
  <body>";

include ('navigation.php');

$query = "select events.location_id, location_name, event_id, event_name
          from " . DKP_EVENTS . " as events
          inner join " . DKP_LOCATIONS . " as locations
          on locations.location_id = events.location_id
          order by location_name asc, event_name asc";
$result = mysql_query ($query);

$output .= "
    <span class=\"listtitle\">events</span>
    <table class=\"list\" cellspacing=\"0\" cellpadding=\"0\">
      <tr class=\"listheader\">
        <td>location</td>
        <td>event</td>
      </tr>";

$i = 0;      
while ($row = mysql_fetch_array ($result))
{
  $i++;

  $output .= "
      <tr class=\"" . ($i & 1 ? "listodd" : "listeven") . "\">
        <td><a href=\"viewlocation.php?locationid=" . $row['location_id'] . "\">" . $row['location_name'] . "</a></td>
        <td><a href=\"viewevent.php?eventid=" . $row['event_id'] . "\">" . $row['event_name'] . "</a></td>
      </tr>";
}

$output .= "
    </table>";

$output .= "
    <a href=\"addevent.php\">add event</a>";

$output .= "
  </body>
</html>";

echo $output;
